<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <my-component :init-count="initnum"></my-component>
    </div>
    <script type="text/javaScript" charset="UTF-8" src="/JS文件/vue.js"></script>
    <script>
        Vue.component("my-component",{
            props:["initCount"],
            template:`<div>
                原始值{{count}}
                <button type="button" @click="add()">改变按原始值</button><br>
                监听:<input type="text" name="" id="" value="" v-model.number="count"/>
                </div>`,
                data(){
                    return {
                        count:this.initCount
                    }
                },
                methods:{
                    add(){
                   
                      this.count++
                     
                    }
                },
                // watch:{
                //     initCount(newV,odV){
                //         this.count=odV
                //     }
                // }
        })

        var vm = new Vue({
            el:'#app',
            data:{
                initnum:100
            }
        })
    </script>
</body>
</html>